package com.viphuli.app.tool.fragment;

import net.simonvt.numberpicker.NumberPicker;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import butterknife.Bind;
import butterknife.OnClick;

import com.viphuli.app.tool.R;

public class DayHourPickerDialogFragment extends BaseProgressBottomDialogFragment {

	@Bind(R.id.number_picker_day)
	protected NumberPicker dayPicker;

	@Bind(R.id.number_picker_hour)
	protected NumberPicker hourPicker;

	private DayHourClickListener clickListener;

	public DayHourPickerDialogFragment(DayHourClickListener clickListener) {
		this.clickListener = clickListener;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		//无标题
		getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);

		return super.onCreateView(inflater, container, savedInstanceState);
	}

	@Override
	protected int obtainContentRes() {
		return R.layout.dialog_day_hour_picker;
	}

	@Override
	protected void initParams() {

	}

	@Override
	protected void initView() {

		dayPicker.setMaxValue(150);
		dayPicker.setMinValue(0);
		dayPicker.setValue(0);
		dayPicker.setFocusable(true);
		dayPicker.setFocusableInTouchMode(true);

		hourPicker.setMaxValue(7);
		hourPicker.setMinValue(0);
		hourPicker.setValue(0);
		hourPicker.setFocusable(true);
		hourPicker.setFocusableInTouchMode(true);

	}

	@Override
	protected void initData() {

	}

	@OnClick(R.id.id_btn_cacel)
	public void clickCancel() {
		
		dismiss();
		
	}

	@OnClick(R.id.id_btn_enter)
	public void clickEnter() {
		
		dismiss();

		int day = dayPicker.getValue();
		int hour = hourPicker.getValue();

		if (clickListener != null)
			clickListener.onEnsure(day, hour);
	}

	public interface DayHourClickListener {
		void onEnsure(int day, int hour);
	}

}
